package com.dingli.service.impl;

import com.dingli.framework.entity.Member;
import com.dingli.framework.entity.Resume;
import com.dingli.framework.mapper.ResumeMapper;
import com.dingli.framework.util.Response;
import com.dingli.service.IResumeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ResumeService implements IResumeService {

    @Autowired
    private ResumeMapper resumeMapper;

    @Override
    public Response<List<Resume>>selectInention(String reIntention) {
        return new Response<>(200,"success", resumeMapper.selectInention(reIntention));
    }

    @Override
    public Response<Resume> ReselectById(Long reID) {
        return new Response<>(200, "success", resumeMapper.ReselectById(reID));
    }

    @Override
    public Response<PageInfo<Resume>> Relist(String search, Integer pageNum, Integer pageSize) {
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        PageHelper.startPage(pageNum, pageSize);
        PageInfo<Resume> info = new PageInfo<>(resumeMapper.Relist(search));
        return new Response<>(200, "success", info);
    }

    @Override
    public Response<Long> Reinsert(Resume resume) {
        int count = resumeMapper.Reinsert(resume);
        if (count > 0) {
            return new Response(200, "success", resume.getReId());
        } else {
            return new Response<>(500, "failed");
        }
    }

    @Override
    public Response<Object> ReupdateById(Resume resume) {
        int count = resumeMapper.ReupdateById(resume);
        if (count > 0) {
            return new Response<>(200, "success");
        } else {
            return new Response<>(500, "failed");
        }
    }

    @Override
    public Response<Object> RedeleteById(Long reID) {
        int count = resumeMapper.RedeleteById(reID);
        if (count > 0) {
            return new Response<>(200, "success");
        } else {
            return new Response<>(500, "failed");
        }
    }

    @Override
    public Response<Object> ReupdateState(String reID) {
        int count = resumeMapper.ReupdateState(reID);
        if (count > 0) {
            return new Response<>(200, "success");
        } else {
            return new Response<>(500, "failed");
        }
    }

    @Override
    public Response<Object> Reupdate(String reID) {
        int count = resumeMapper.Reupdate(reID);
        if (count > 0) {
            return new Response<>(200, "success");
        } else {
            return new Response<>(500, "failed");
        }
    }

    @Override
    public Response<List<Resume>> ReselectState(String reState) {
        List<Resume> resumes= resumeMapper.ReselectState(reState);
        return new Response<>(200,"success", resumeMapper.ReselectState(reState));
    }

    @Override
    public Response<List<Resume>> ReselectState1(String reState) {
        List<Resume> resumes = resumeMapper.ReselectState1(reState);
        return new Response<>(200,"success", resumeMapper.ReselectState1(reState));
    }

    @Override
    public Response<List<Resume>> ReAll(String reID) {
        return new Response<>(200,"success", resumeMapper.ReAll(reID));
    }

    @Override
    public Response<List<Resume>> Reselect(String reIntention) {
        return new Response<>(200,"success", resumeMapper.Reselect(reIntention));
    }


}

